/*
@Author   : Uyynot
@Email    : uyynot@qq.com
@Time     : 2024/1/12 17:58
@File     : database.go
@Project  : gohub
@Desc     :
*/
package config

import "gohub/pkg/config"

func init() {
	config.Add("database", func() map[string]any {
		return map[string]any{
			//默认数据库
			"connection": config.Env("DB_CONNECTION", "mysql"),
			"mysql": map[string]any{
				//数据库连接信息
				"host":     config.Env("DB_HOST", "127.0.0.1"),
				"port":     config.Env("DB_PORT", "3306"),
				"database": config.Env("DB_DATABASE", "gohub"),
				"username": config.Env("DB_USERNAME", "root"),
				"password": config.Env("DB_PASSWORD", "admin888"),
				"charset":  "utf8mb4",

				// 连接池配置
				"max_idle_connections": config.Env("DB_MAX_IDLE_CONNECTIONS", 100),
				"max_open_connections": config.Env("DB_MAX_OPEN_CONNECTIONS", 25),
				"max_life_seconds":     config.Env("DB_MAX_LIFE_SECONDS", 5*60),
			},

			"sqlite": map[string]any{
				"database": config.Env("DB_SQL_FILE", "database/database.db"),
			},
		}
	})
}
